﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DoAnOOP.SinhVien;
using DoAnOOP.NQL;
namespace DoAnOOP
{
    public partial class frmMain : Office2007RibbonForm
    {
        public static string mssv = "";
        public static string password = "";
        public static string QuyenHan = "";
        public static string TimeFormat = "";

        public frmMain()
        {
            InitializeComponent();
            System.Globalization.DateTimeFormatInfo n = System.Globalization.DateTimeFormatInfo.CurrentInfo;
            TimeFormat = n.ShortDatePattern + " " + n.LongTimePattern;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            frmLoginServer myLoginServer = new frmLoginServer();
            myLoginServer.ShowDialog();
            DialogResult dr = myLoginServer.DialogResult;
            if (dr == DialogResult.Cancel)
                Application.Exit();
            else
            {
                LoadLoginUser();
            }
        }

        private void LoadLoginUser()
        {
            frmLogIn _frmLogIn = new frmLogIn(this);
            _frmLogIn.ShowDialog();
            if (_frmLogIn.DialogResult == DialogResult.Cancel)
            {
                btnDangNhap.Enabled = true;
                ribbonTabItem1.Checked = true;
            }
            else
            {
                btnDangNhap.Enabled = false;
            }

        }
        private void btnSVLyLich_Click(object sender, EventArgs e)
        {
            btnDong_Click(sender, e);
            ribbonTabItem1.Checked = true;
            menuAdmin.Visible = false;
            menuGV.Visible = false;
            menuSV.Visible = false;
            LoadLoginUser();
        }
        public void setQuyenHan()
        {
            switch (QuyenHan)
            {
                case "SV":
                    menuSV.Visible = true;
                    menuSV.Checked = true;
                    break;
                case "GV":
                    menuGV.Visible = true;
                    menuGV.Checked = true;
                    break;
                case "admin":
                    menuAdmin.Visible = true;
                    menuAdmin.Checked = true;
                    break;
            }
            this.Refresh();
        }

        private void buttonItem6_Click(object sender, EventArgs e)
        {
            frmLyLichGV frmMyLylich = new frmLyLichGV();
            frmMyLylich.MdiParent = this;
            frmMyLylich.Show();
        }

        private void btnSVDangxuat_Click(object sender, EventArgs e)
        {
            btnDong_Click(sender, e);
            ribbonTabItem1.Checked = true;
            menuAdmin.Visible = false;
            menuGV.Visible = false;
            menuSV.Visible = false;
            LoadLoginUser();
        }

        private void btnGVDangxuat_Click(object sender, EventArgs e)
        {
            btnDong_Click(sender, e);
            ribbonTabItem1.Checked = true;
            menuAdmin.Visible = false;
            menuGV.Visible = false;
            menuSV.Visible = false;
            LoadLoginUser();
            btnDangNhap.Enabled = false;
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            btnDong_Click(sender, e);
            menuAdmin.Visible = false;
            menuGV.Visible = false;
            menuSV.Visible = false;
            LoadLoginUser();
            btnDangNhap.Enabled = true;
        }


        private void buttonItem6_Click_1(object sender, EventArgs e)
        {
            Form1_Load(sender, e);
        }

        private void buttonItem2_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.Cascade);
        }

        private void buttonItem3_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.TileVertical);
        }

        private void buttonItem4_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void btnDong_Click(object sender, EventArgs e)
        {
            foreach (Form frmChild in this.MdiChildren)
            {
                frmChild.Close();
            }
        }


        private void btnSVLyLich_Click_1(object sender, EventArgs e)
        {
            frmSinhVien frm = new frmSinhVien();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnSVThongTin_Click(object sender, EventArgs e)
        {
            frmThongTin frm = new frmThongTin();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnQLSV_Click(object sender, EventArgs e)
        {
            frmQLSV frm = new frmQLSV();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnQLGV_Click(object sender, EventArgs e)
        {

            frmQLGV frm = new frmQLGV();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnQLMH_Click(object sender, EventArgs e)
        {
            frmQLMH frm = new frmQLMH();
            frm.MdiParent  = this;
            frm.Show();
        }

        private void btnSVKetqua_Click(object sender, EventArgs e)
        {
            frmKetQua_SinhVien frm = new frmKetQua_SinhVien();
            frm.MdiParent = this;
            frm.Show();
        }


    }
}
